package com.ebt.m.utils;

import android.databinding.BindingAdapter;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.ebt.m.AppContext;
import com.ebt.m.R;
import com.ebt.m.data.bean.UserInfo;
import com.ebt.m.utils.imageloader.ImageLoader;
import com.ebt.m.utils.imageloader.ImageLoaderUtil;

/**
 * Created by andy on 2017/8/15.
 */

public class BindingAttrSetManager {
    @BindingAdapter({"companyname"})
    public static void companyName(TextView textView, int validateStatus) {
        UserInfo userInfo = AppContext.getCurrentUser();
        if (userInfo.isRegisterCompany()) {
            textView.setText(userInfo.getCompanyInfo().getNameForZyj());
            textView.setVisibility(View.VISIBLE);
        } else {
            textView.setVisibility(View.GONE);
        }
    }

    @BindingAdapter({"companylogo"})
    public static void compayLogo(ImageView imageView, int validateStatus) {
        UserInfo userInfo = AppContext.getCurrentUser();
        if (userInfo.isRegisterCompany()) {
            Glide.with(AppContext.getInstance())
                    .load(userInfo.getCompanyInfo().getMiniLogoUrl())
                    .error(R.drawable.empty_photo)
                    .dontAnimate()
                    .into(imageView);
            imageView.setVisibility(View.VISIBLE);
        } else {
            imageView.setVisibility(View.GONE);
        }
    }
}
